﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tetris
{
    class TetrisMain
    {
        public const int WorldRows = 20;
        public const int WorldCols = 10;

        public const int SpeedIncreaseFactorInPercent = 5;
        public const int DifferentShapesCount = 7;

        public const int ConsoleWindowHeight = 24;
        public const int ConsoleWindowWidth = 32;
        public const ConsoleColor ConsoleBackgroundColor = ConsoleColor.Gray;

        static void Main()
        {
            Console.SetWindowSize(TetrisMain.ConsoleWindowWidth, TetrisMain.ConsoleWindowHeight);
            Console.SetBufferSize(TetrisMain.ConsoleWindowWidth, TetrisMain.ConsoleWindowHeight);

            //Console.BackgroundColor = ConsoleBackgroundColor;

            IRenderer renderer = new ConsoleRenderer(TetrisMain.WorldRows, TetrisMain.WorldCols);
            IUserInterface keyboard = new KeyboardInterface();

            Engine gameEngine = new Engine(renderer, keyboard, TetrisMain.WorldRows, TetrisMain.WorldCols, 500);

            keyboard.OnLeftPressed += (sender, eventInfo) =>
            {
                gameEngine.MoveLeft();
            };

            keyboard.OnRightPressed += (sender, eventInfo) =>
            {
                gameEngine.MoveRight();
            };

            keyboard.OnUpPressed += (sender, eventInfo) =>
            {
                gameEngine.Rotate();
            };

            keyboard.OnDownPressed += (sender, eventInfo) =>
            {
                gameEngine.Drop();
            };

            gameEngine.Run();
        }
    }
}
